<?php
/**
 *author:韩帅
 *createtime:2017/6/23 10:15
 *description:
 */
namespace App\Http\Controllers\App;

use Illuminate\Http\Request;
use App\Http\Controllers\App\BaseController;
use App\Models\BfLines;
use Illuminate\Support\Facades\DB;

class BfLinesController extends BaseController
{
    /**
     * 平台店铺流水查看
     */
    public function bfLins(Request $request)
    {
        $return          = []; //存放取出的数据
        $newArr          = []; //存放处理后的数据
        $delivery_point  = $request->input('delivery_point','');
        $s_time          = $request->input('s_time');//开始时间
        $e_time          = $request->input('e_time');//结束时间

        //必填参数判断
        if (empty($delivery_point)) {

            return self::error('商户ID不能为空');
        }

        $obj = BfLines::where('delivery_point',$delivery_point);

        //筛选条件判断

        if($s_time > 0){

            $obj = $obj->where('created_at','>=',$s_time);
        }

        if($e_time > 0){

            $obj = $obj->where('created_at','<=',$e_time);
        }

        $data   = $obj->orderBy('created_at','desc')->paginate($this->pagesize)->toArray();

        $return = $data;

        if (empty($return['data'])) {

            return self::json($return,'获取数据为空');
        }

        $objB   = new BfLines();

        $newArr = $objB->translate($return);

        return self::json($newArr,'成功');
    }
}